package client.demo;

import codec.DemoProtocolCodec;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * 与服务端类似
 */
public class SimpleChatClientInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    public void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //pipeline.addLast(new ProtobufVarint32FrameDecoder());
        //pipeline.addLast(new ProtobufDecoder(Ecg.EcgResult.getDefaultInstance()));
        //pipeline.addLast(new ProtobufVarint32LengthFieldPrepender());
        //pipeline.addLast(new ProtobufEncoder());
        //pipeline.addLast(new ProtobufClientHandler());

//        pipeline.addLast(new ByteArrayDecoder());
//        pipeline.addLast(new ByteArrayEncoder());
//        pipeline.addLast(new MsgDecode());
//        pipeline.addLast(new MsgEncode());
        pipeline.addLast(new DemoProtocolCodec());
        pipeline.addLast(new SimpleChatClientHandler());

        //pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
        //pipeline.addLast("decoder", new StringDecoder());
        //pipeline.addLast("encoder", new StringEncoder());
        //pipeline.addLast("handler", new ProtobufClientHandler());
    }
}
